<?php
/*
 * 阿里支付
 */
namespace app\home\controller;

use app\common\controller\Base;
use app\common\model\System;
use alipay\wappay\service\AlipayTradeService;
use alipay\wappay\buildermodel\AlipayTradeWapPayContentBuilder;

class Alipay extends IndexBase
{

    protected function initialize()
    {
        parent::initialize();
    }

    public function index()
    {
    	if ($this->request->isPost())
    	{
            $param = $this->request->param();
			$config = System::get_config_by_code('alipay');
			//商户订单号，商户网站订单系统中唯一订单号，必填
		    $out_trade_no = build_order_no();
		    //订单名称，必填
		    $subject = '2017春秋季时尚潮长袖上衣气质女神套装秋装新款女装 三件套韩版';
		    //付款金额，必填
		    $total_amount = 499.00;
		    //商品描述，可空
		    $body = '均码';
		    //超时时间
		    $timeout_express="30m";
		    $payRequestBuilder = new AlipayTradeWapPayContentBuilder();
		    $payRequestBuilder->setBody($body);
		    $payRequestBuilder->setSubject($subject);
		    $payRequestBuilder->setOutTradeNo($out_trade_no);
		    $payRequestBuilder->setTotalAmount($total_amount);
		    $payRequestBuilder->setTimeExpress($timeout_express);
		    $payResponse = new AlipayTradeService($config);
		    $result=$payResponse->wapPay($payRequestBuilder,$config['return_url'],$config['notify_url']);

		    return ;
		}
		return $this->fetch();
    }

}
